-
Couldn't load subscription status.
- Fork 416
⚡(backend) move email sending to celery #1236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/backend/core/tasks/mail.py
Outdated
| try: | ||
| document = models.Document.objects.get(id=document_id) | ||
| document.send_email(subject, emails, context, language) | ||
| except models.Document.DoesNotExist: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to not fail silently. Let the exception bubbles, your monitoring system will warn you about this error. Because it is not normal to not find the document here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Removing the try/except clauses should allow the exception to bubble up then, right?
Thank you !
src/backend/core/tasks/mail.py
Outdated
| document = models.Document.objects.get(id=document_id) | ||
| sender = models.User.objects.get(id=sender_id) | ||
| document.send_invitation_email(email, role, sender, language) | ||
| except (models.Document.DoesNotExist, models.User.DoesNotExist): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
21e721d to
ce02929
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell me if you have trouble
Move send_email and send_invitation_email operations to Celery tasks to prevent API endpoints from blocking while sending emails. Signed-off-by: Johann LORBER <[email protected]>
fb06c96 to
cb92192
Compare
Makes email sending asynchronous by moving email operations to Celery tasks, preventing API endpoints from blocking.
This pull request addresses issue #1143